package com.example.mytayunapi.Mapper;
import com.example.mytayunapi.Entity.userInfo;
import com.example.mytayunapi.Vo.UserProduct;
import org.apache.ibatis.annotations.*;
import org.springframework.web.bind.annotation.GetMapping;

import java.util.List;

@Mapper
public interface userInfoMapper {
    @Select("select Nick_name,aureole from user where School_degree=#{School_degree}")
    List<userInfo>getNickname(String School_degree);

    @Select("SELECT * FROM tayun.user")
    List<userInfo> getUserInfo();

    @Select("SELECT * FROM tayun.user WHERE School_degree LIKE CONCAT('%', #{School_degree}, '%')")
    List<userInfo> getSchool_degree(String School_degree);

    @Update("update user set Nick_name = #{Nick_name},phone = #{phone},password = #{password},aureole = #{aureole} where School_degree = #{School_degree}")
    Integer updateUserInfo(userInfo userinfo);

    @Insert("insert into user(School_degree,Nick_name,phone,password) values(#{School_degree},#{Nick_name},#{phone},#{password})")
    Integer insertUserInfo(userInfo userinfo);

    @Select("SELECT * FROM tayun.user where School_degree = #{School_degree} and password = #{password}")
    userInfo getUserdegreeApass(@Param("School_degree") String School_degree, @Param("password") String password);

    @Select("select * from user where School_degree = #{School_degree}")
    List<userInfo> getUserdegree(String School_degree);

    @Update("update user set Nick_name =#{Nick_name} ,aureole=#{aureole},password=#{password}, phone = #{phone} where School_degree = #{School_degree}")
    Integer changeUserInfo(userInfo userinfo );

    @Update("update user set Login_1 = #{Login_1} where School_degree = #{School_degree}")
    Integer changeUserInfoLogin(userInfo userinfo);

    @Update("update user set password = #{password} where School_degree = #{School_degree}")
    Integer changeUserInfoPassword(userInfo userinfo);

    @Select("SELECT School_degree FROM tayun.user where School_degree = #{School_degree}")
    String getSchool_number(String School_degree);

    @Select("SELECT name FROM tayun.user where School_degree = #{School_degree}")
    String getSchool_name(String School_degree);

    @Update("update user set name = #{name} where School_degree = #{School_degree}")
    Integer updateUserInfoName(userInfo userinfo);

    @Select("select * from user where School_degree = (SELECT School_degree FROM tayun.products where Product_id = #{Product_id})")
    List<UserProduct> getmaijiaxuehao(Integer Product_id);

    @Update("update user\n" +
            "set Login_1 = '0'\n" +
            "where School_degree = #{School_degree}")
    Integer updateUsersInfoName(userInfo userinfo);

    @Update("update user\n" +
            "set Login_1 = '1'\n" +
            "where School_degree = #{School_degree}")
    Integer updateUsersQXInfoName(userInfo userinfo);

    @Select("select * from user where School_degree = #{School_degree}")
    List<userInfo> getyonghu(String School_degree);

}